/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jdAdministrarMovimientos.java
 *
 * Created on 10-dic-2010, 8:18:38
 */

package GestionMovimientos;

import administracion.delegate.GestionPedidosDelegate;
import administracion.helper.Utiles_MensajesDialogo;
import administracion.helper.Utiles_Tabla;
import java.awt.event.KeyEvent;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.beansbinding.AutoBinding;
import org.jdesktop.beansbinding.BindingGroup;
import org.jdesktop.beansbinding.ELProperty;
import org.jdesktop.swingbinding.JTableBinding;
import org.jdesktop.swingbinding.SwingBindings;
import suministros.ejb30.TO.DetalleMovimientoTO;
import suministros.ejb30.TO.MovimientoTO;
import suministros.ejb30.entity.DetalleMovimiento;
import suministros.ejb30.entity.DetalleMovimientoPK;

/**
 *
 * @author Diana
 */
public class jdAdministrarMovimientosSalidas extends javax.swing.JDialog{
    List<DetalleMovimientoTO> listadetalles= new ArrayList<DetalleMovimientoTO>();
    private JTableBinding jTableBinding;
    private BindingGroup bindingGroup;
    private String codigomov;
    private int tipo;
    private  java.awt.Frame  parent;
    private jifConsultarSalidas  padre;
    /** Creates new form jdAdministrarMovimientos */
    public jdAdministrarMovimientosSalidas(java.awt.Frame parent, jifConsultarSalidas  padre,boolean modal,String codigo, int tipo) {
        super(parent, modal) ;
        initComponents();
        this.parent=parent;
        this.codigomov=codigo;
        this.tipo=tipo;
        this.padre=padre;
        if(tipo== 1){
            buscarMovimiento();
            getDatosDetalleMovimiento();
        }
    }
public void buscarMovimiento(){
    String codigo;
    if(tipo==1){
    codigo=codigomov;
    }
    else{
    codigo= this.jtfCodigo.getText();
    }
    MovimientoTO mov= new MovimientoTO();
    try {
        mov=GestionPedidosDelegate.getInstance().getMovimientoModificar(codigo);
    } catch (Exception ex) {
        Logger.getLogger(jdAdministrarMovimientosSalidas.class.getName()).log(Level.SEVERE, null, ex);
    }
    if(mov!=null){
        this.jtfCodigoMov.setText(mov.getCodigo());
        this.jtfFecha.setText(mov.getFecha());
        this.jtfTipo.setText(mov.getTipoMovimiento());
        this.jtfRucCosechador.setText(mov.getRucCosechador());
        this.jtfRucProveedor.setText(mov.getRuc());
        this.jtfCosechador.setText(mov.getCosechador());
        this.jtfProveedor.setText(mov.getProveedor());
    }
   }
   public void getDatosDetalleMovimiento(){
     String codigo= this.jtfCodigoMov.getText();
        try {
            listadetalles = GestionPedidosDelegate.getInstance().getDetallesMovimientoModificar(codigo);
        } catch (Exception ex) {
            Logger.getLogger(jdAdministrarMovimientosSalidas.class.getName()).log(Level.SEVERE, null, ex);
        }
     cargarDatos();
   }
    public void cargarDatos(){
    this.bindingGroup = new BindingGroup();
    this.jTableBinding = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ, this.listadetalles, this.jTable1);

    JTableBinding.ColumnBinding columnBinding0 = this.jTableBinding.addColumnBinding(ELProperty.create("${codsuministro}"));

    columnBinding0.setColumnName("Codigo");
    columnBinding0.setColumnClass(String.class);
    columnBinding0.setEditable(false);

    JTableBinding.ColumnBinding columnBinding1 = this.jTableBinding.addColumnBinding(ELProperty.create("${dessuministro}"));

    columnBinding1.setColumnName("Suministro");
    columnBinding1.setColumnClass(String.class);
    columnBinding1.setEditable(false);

    JTableBinding.ColumnBinding columnBinding2 = this.jTableBinding.addColumnBinding(ELProperty.create("${cantidad}"));

    columnBinding2.setColumnName("Cantidad");
    columnBinding2.setColumnClass(BigDecimal.class);
    columnBinding2.setEditable(true);

    JTableBinding.ColumnBinding columnBinding3 = this.jTableBinding.addColumnBinding(ELProperty.create("${precio}"));

    columnBinding3.setColumnName("Precio");
    columnBinding3.setColumnClass(BigDecimal.class);
    columnBinding3.setEditable(true);

    JTableBinding.ColumnBinding columnBinding4 = this.jTableBinding.addColumnBinding(ELProperty.create("${precioCos}"));

    columnBinding4.setColumnName("PrecioCosechador");
    columnBinding4.setColumnClass(BigDecimal.class);
    columnBinding4.setEditable(true);

    
    this.bindingGroup.addBinding(this.jTableBinding);
    this.bindingGroup.bind();
    //MiTablePrint.autoSizeTableColumns(jtDetalleSuministro);
    try {
          int[] porcentajes= {15,35,10,10,10};
          Utiles_Tabla.definirAnchoColumnasJTable(this.jTable1, porcentajes);
          // MiTablePrint.autoSizeTableColumns(jtDetalleSuministro);
        } catch (Exception ex) {
            Logger.getLogger(jifConsultarIngresos.class.getName()).log(Level.SEVERE, null, ex);
        }


  }
    public void modificarMovimiento() throws Exception{
        List<DetalleMovimiento> lista= new ArrayList<DetalleMovimiento>();
        for(int i=0; i<this.listadetalles.size(); i++){
            DetalleMovimientoTO detalle=listadetalles.get(i);
            DetalleMovimiento detallemov= new DetalleMovimiento();
            DetalleMovimientoPK pk= new DetalleMovimientoPK();
            pk.setIdMovimiento(this.jtfCodigoMov.getText().trim());
            pk.setNrodetalleMovimiento(detalle.getCorrelativo());
            detallemov.setDetalleMovimientoPK(pk);
            detallemov.setCantidad(detalle.getCantidad());
            detallemov.setPrecio(detalle.getPrecio());
            detallemov.setPrecioCosechador(detalle.getPrecioCos());
            lista.add(detallemov);

        }
         GestionPedidosDelegate.getInstance().modificarIngresoCarga(lista);
         GestionPedidosDelegate.getInstance().ajustarIngresoCarga(lista);
    }
 public void eliminarMovimiento() throws Exception{
        List<DetalleMovimiento> lista= new ArrayList<DetalleMovimiento>();
        for(int i=0; i<this.listadetalles.size(); i++){
            DetalleMovimientoTO detalle=listadetalles.get(i);
            DetalleMovimiento detallemov= new DetalleMovimiento();
            DetalleMovimientoPK pk= new DetalleMovimientoPK();
            pk.setIdMovimiento(this.jtfCodigoMov.getText().trim());
            pk.setNrodetalleMovimiento(detalle.getCorrelativo());
            detallemov.setDetalleMovimientoPK(pk);
            lista.add(detallemov);

        }
         GestionPedidosDelegate.getInstance().eliminarIngresoCarga(lista);
          GestionPedidosDelegate.getInstance().ajustarIngresoCarga(lista);

    }



    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jtfCodigo = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jtfCodigoMov = new javax.swing.JTextField();
        jtfFecha = new javax.swing.JTextField();
        jtfProveedor = new javax.swing.JTextField();
        jtfCosechador = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jtfTipo = new javax.swing.JTextField();
        jtfRucProveedor = new javax.swing.JTextField();
        jtfRucCosechador = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jbtAceptar = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jbBuscar = new javax.swing.JButton();
        jbtEliminar = new javax.swing.JButton();

        setTitle("ADMINISTRAR MOVIMIENTOS ALMACEN");

        jLabel1.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel1.setText("CODIGO DE MOVIMIENTO");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DATOS DE MOVIMIENTO", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(0, 0, 255))); // NOI18N

        jLabel2.setText("CODIGO:");

        jLabel3.setText("FECHA:");

        jLabel4.setText("PROVEEDOR:");

        jLabel5.setText("COSECHADOR:");

        jtfCodigoMov.setEnabled(false);

        jtfFecha.setEnabled(false);

        jtfProveedor.setEnabled(false);

        jtfCosechador.setEnabled(false);

        jLabel6.setText("TIPO MOVIMIENTO");

        jtfTipo.setEnabled(false);

        jtfRucProveedor.setEnabled(false);

        jtfRucCosechador.setEnabled(false);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(jLabel2)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jtfCodigoMov, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(41, 41, 41)
                        .addComponent(jLabel3)
                        .addGap(18, 18, 18)
                        .addComponent(jtfFecha, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jtfTipo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 271, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jtfRucProveedor)
                            .addComponent(jtfRucCosechador, javax.swing.GroupLayout.DEFAULT_SIZE, 95, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jtfCosechador)
                            .addComponent(jtfProveedor, javax.swing.GroupLayout.DEFAULT_SIZE, 339, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jtfCodigoMov, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtfFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jtfTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(jtfRucProveedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jtfRucCosechador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jtfProveedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtfCosechador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DETALLES DE MOVIMIENTO", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(0, 0, 255))); // NOI18N

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Codigo", "Descripcion", "Cantidad", "PrecioProv", "PrecioCos"
            }
        ));
        jScrollPane1.setViewportView(jTable1);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 229, Short.MAX_VALUE)
        );

        jbtAceptar.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jbtAceptar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_ok.png"))); // NOI18N
        jbtAceptar.setMnemonic('A');
        jbtAceptar.setText("ACEPTAR");
        jbtAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtAceptarActionPerformed(evt);
            }
        });
        jbtAceptar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbtAceptarKeyPressed(evt);
            }
        });

        jButton2.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_cancel.png"))); // NOI18N
        jButton2.setMnemonic('C');
        jButton2.setText("CANCELAR");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jbBuscar.setFont(new java.awt.Font("Arial", 1, 12));
        jbBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/find.png"))); // NOI18N
        jbBuscar.setMnemonic('B');
        jbBuscar.setText("BUSCAR");
        jbBuscar.setToolTipText("Cancelar la Operacion");
        jbBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbBuscarActionPerformed(evt);
            }
        });
        jbBuscar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbBuscarKeyPressed(evt);
            }
        });

        jbtEliminar.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jbtEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/editdelete.png"))); // NOI18N
        jbtEliminar.setMnemonic('C');
        jbtEliminar.setText("ELIMINAR");
        jbtEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtEliminarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(78, 78, 78)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jtfCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jbBuscar)
                .addGap(131, 131, 131))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 587, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(164, 164, 164)
                .addComponent(jbtAceptar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtEliminar)
                .addGap(81, 81, 81)
                .addComponent(jButton2)
                .addContainerGap(27, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtfCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbBuscar))
                .addGap(13, 13, 13)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jbtEliminar)
                        .addComponent(jbtAceptar))
                    .addComponent(jButton2))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbtAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtAceptarActionPerformed
         int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro que desea realizar la modificacion",
                "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
        if(res==javax.swing.JOptionPane.YES_OPTION){
            try {
                modificarMovimiento();
                Utiles_MensajesDialogo.mensajeExito();
                padre.buscar();
            } catch (Exception ex) {
                Utiles_MensajesDialogo.mensajeError("No se pudo completar la transaccion");
                Logger.getLogger(jdAdministrarMovimientosSalidas.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_jbtAceptarActionPerformed

    private void jbtAceptarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbtAceptarKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jbtAceptar.doClick();
        }
}//GEN-LAST:event_jbtAceptarKeyPressed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro de salir?",
                "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
        if(res==javax.swing.JOptionPane.YES_OPTION){
            this.dispose();
        }
}//GEN-LAST:event_jButton2ActionPerformed

    private void jbBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbBuscarActionPerformed
        if(this.jtfCodigo.getText().compareTo("")>0){
            this.buscarMovimiento();
            this.getDatosDetalleMovimiento();
        }
}//GEN-LAST:event_jbBuscarActionPerformed

    private void jbBuscarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbBuscarKeyPressed

        if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jbBuscar.doClick();
        }
}//GEN-LAST:event_jbBuscarKeyPressed

    private void jbtEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtEliminarActionPerformed
         int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro que desea eliminar todo el movimiento?",
                "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
        if(res==javax.swing.JOptionPane.YES_OPTION){
            try {
                this.eliminarMovimiento();
                Utiles_MensajesDialogo.mensajeExito();
            } catch (Exception ex) {
                Utiles_MensajesDialogo.mensajeError("No se pudo completar la transaccion");
                Logger.getLogger(jdAdministrarMovimientosSalidas.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_jbtEliminarActionPerformed

    /**
    * @param args the command line arguments
    */
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JButton jbBuscar;
    private javax.swing.JButton jbtAceptar;
    private javax.swing.JButton jbtEliminar;
    private javax.swing.JTextField jtfCodigo;
    private javax.swing.JTextField jtfCodigoMov;
    private javax.swing.JTextField jtfCosechador;
    private javax.swing.JTextField jtfFecha;
    private javax.swing.JTextField jtfProveedor;
    private javax.swing.JTextField jtfRucCosechador;
    private javax.swing.JTextField jtfRucProveedor;
    private javax.swing.JTextField jtfTipo;
    // End of variables declaration//GEN-END:variables

}
